<template>
	<view class="container">
		<view class="example">
			<view style="font-size: 27rpx; margin: 16rpx;color: red;">请完成以下实名认证，以保证账号功能正常可用。未完成实名或许会影响您的提现，及部分重要功能的使用权限。
			</view>

			<uni-forms ref="form" :model="user" labelWidth="120px">
				<uni-forms-item label="姓名" name="name">
					<uni-easyinput v-model="user.name" placeholder="请输入姓名" />
				</uni-forms-item>
				<uni-forms-item label="证件类型" name="cardType">
					<uni-data-select v-model="baseFormData.skills" :localdata="skillsRange">
					</uni-data-select>
					<!-- <uni-data-checkbox v-model="user.cardType" multiple :localdata="hobbys" /> -->
					<!-- <uni-easyinput v-model="user.cardType" placeholder="请输入证件类型" /> -->
				</uni-forms-item>
				<uni-forms-item label="证件号码" name="email">
					<uni-easyinput v-model="user.email" placeholder="请输入邮箱" />
				</uni-forms-item>
				<uni-forms-item label="证件有效期开始" name="sex" required>
					<uni-data-checkbox v-model="user.sex" :localdata="sexs" />
				</uni-forms-item>
				<uni-forms-item label="证件有效期结束" name="sex" required>
					<uni-data-checkbox v-model="user.sex" :localdata="sexs" />
				</uni-forms-item>
				<uni-forms-item label="居民身份证照片" name="sex" required>
					<uni-data-checkbox v-model="user.sex" :localdata="sexs" />
				</uni-forms-item>
			</uni-forms>
			<button type="primary" @click="submit">提交</button>
		</view>
	</view>
</template>

<script>
	import {
		getUserProfile
	} from "@/api/system/user"
	import {
		updateUserProfile
	} from "@/api/system/user"

	export default {
		data() {
			return {
				user: {
					name: "",
					cardType: "",
					cardNo: "",
					starTime: "",
					endTime: "",
					fontImg: "",
					backImg: ""
				},
				skillsRange: [{
						value: 0,
						text: "编程"
					},
					{
						value: 1,
						text: "绘画"
					},
					{
						value: 2,
						text: "运动"
					},
				],
				rules: {
					nickName: {
						rules: [{
							required: true,
							errorMessage: '用户昵称不能为空'
						}]
					},
					userName: {
						rules: [{
							required: true,
							errorMessage: '手机号码不能为空'
						}, {
							pattern: /^1[3|4|5|6|7|8|9][0-9]\d{8}$/,
							errorMessage: '请输入正确的手机号码'
						}]
					},
					email: {
						rules: [{
							required: true,
							errorMessage: '邮箱地址不能为空'
						}, {
							format: 'email',
							errorMessage: '请输入正确的邮箱地址'
						}]
					}
				}
			}
		},
		onLoad() {
			this.getUser()
		},
		onReady() {
			this.$refs.form.setRules(this.rules)
		},
		methods: {
			getUser() {
				getUserProfile().then(response => {
					this.user = response.data
				})
			},
			submit(ref) {
				this.$refs.form.validate().then(res => {
					updateUserProfile(this.user).then(response => {
						this.$modal.msgSuccess("修改成功")
					})
				})
			}
		}
	}
</script>

<style lang="scss">
	page {
		// background-color: #ffffff;
		background: linear-gradient(180deg, #c4d6ff, #f7f8fa);
	}

	.example {
		padding: 32rpx;
		border-radius: 16rpx;
		margin: 32rpx;
		background-color: #fff;

	}

	.segmented-control {
		margin-bottom: 15px;
	}

	.button-group {
		margin-top: 15px;
		display: flex;
		justify-content: space-around;
	}

	.form-item {
		display: flex;
		align-items: center;
		flex: 1;
	}

	.button {
		display: flex;
		align-items: center;
		height: 35px;
		line-height: 35px;
		margin-left: 10px;
	}
</style>